﻿// JScript 文件

function Panel()
{
    this.m_handle = document.getElementById("divPanel");
    this.ShowPanel = function(DiryList)
    {
        this.m_handle.innerHTML = '';
        
        for(var i = 0; i < DiryList.nCurCount; i++)
        {
//        var ImgPath = "/AspxPath/UploadFiles" + Path + "/" + FileInfo.Name;
//            ImgPath = ImgPath.replace(/(\\)/g,"/");
//            var strImgPath = "../../.." + ImgPath;
//            var strHTML = '<div class="divFile">' + 
//                            '<div class="divImage" id="div_'+FileInfo.ID+'">' + 
//                                '<img id="img_'+FileInfo.ID+'" height="19" alt="'+FileInfo.Name+'" src="'+strImgPath+'"' + ' onload="resizeImage(this, 134, 100);" width="20" /><script>setTimeout(function(){document.getElementById("img_'+FileInfo.ID+'").src="";document.getElementById("img_'+FileInfo.ID+'").src=document.getElementById("img_'+FileInfo.ID+'").src;},1000)</script>' +
//                            '</div>' +
//                            '<input type="checkbox" value="'+ImgPath+'" />' +
//                            '<a title="'+FileInfo.Name+'">'+FileInfo.Name +
//                            '</a>' +
//                        '</div>';
//                        return strHTML;
            var FileInfo = DiryList.FileList[i];
            var ImgPath = "/AspxPath/UploadFiles" + DiryList.Path + "/" + FileInfo.Name;
            ImgPath = ImgPath.replace(/(\\)/g,"/");
            var strImgPath = "../../.." + ImgPath;
            var divFile = document.createElement("div");
            divFile.className="divFile";
            divFile.onmouseover = function()
            {
                this.childNodes[1].style.display = 'block';
            }
            divFile.onmouseleave = function()
            {
                this.childNodes[1].style.display = 'none';
            }
            
            var divImage = document.createElement("div");
            divImage.id="div_Image_" + i;
            divImage.className="divImage";
            
            //图片
            var imgID = "img_" + i;
            var img = document.createElement("img");
            img.id=imgID;
            img.src= strImgPath;
            img.alt= FileInfo.Name;
	        img.onclick = function()
	        {
	            window.open(this.src);
	        };
	        img.onload = function()
	        {
	            resizeImage(this, 134, 100);
	        };
	                    
            //链接
            var a = document.createElement("a");
            a.innerHTML = FileInfo.Name;
            a.title=FileInfo.Name;
            a.href=strImgPath;
            a.target="_blank";
//            var chk = document.createElement("input");
//            chk.type="checkbox";
//            chk.value = ImgPath;
//            chk.onclick = function()
//            {
//                return CViewMgr.sm_viewMgr.ShowCheck(this);
//            }
            
            divImage.appendChild(img);
            divFile.appendChild(divImage);
            divFile.innerHTML += '<div class="divAdd"><img src="../../images/drop-add.gif" alt="选择" style="cursor:hand;" onclick=\'AddItem("'+imgID+'");\' />&nbsp;&nbsp;<img src="../../images/state1.gif" alt="删除" style="cursor:hand;" onclick=\'Panel.OnDelItem("'+DiryList.Path + '/' + FileInfo.Name+'","'+ FileInfo.ID +'");\' /></div>';
//            divFile.appendChild(chk);
            divFile.appendChild(a);
            
            this.m_handle.appendChild(divFile);
        }
    }
}

Panel.OnDelItem = function(strPath, strID)
{
    try
    { 
        if(confirm("确定要删除吗?"))
        {
            CViewMgr.sm_viewMgr.m_viewPagePannel.m_object.DelID = strID;
            CViewMgr.sm_viewMgr.m_viewPagePannel.m_object.DelName = strPath;
            CControl.sm_instance.OnMessage("OnClickDelItem", CControl.sm_ActionList.clickDelItem, CViewMgr.sm_viewMgr.m_viewPagePannel.m_object);
        }
    }
    catch(e)
    {
        alert(e.Message);
    }
}